#ifndef _PILINK_UDP_LINUX_H_
#define _PILINK_UDP_LINUX_H_

#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>

struct pilink_udp_socket_s{
    struct sockaddr_in local_addr;
    int local_port;
    int local_addr_len;

    struct sockaddr_in dest_addr;
    int dest_port;
    int dest_addr_len;

    struct sockaddr_in recved_addr;
    int  recved_port;
    int  recved_addr_len;
    char recved_ip[32];

    int  socket_fd;
    
    char dest_ip[32];
};


#ifdef __cplusplus
extern "C" {
#endif


int  pilink_udp_socket_init(struct pilink_udp_socket_s *net, int local_port);   
int  pilink_udp_socket_deinit(struct pilink_udp_socket_s *net);  
void pilink_udp_socket_set_dest_addr(struct pilink_udp_socket_s *net, char *ip, int port );
int  pilink_udp_socket_read(struct pilink_udp_socket_s *net, void *buffer, int size);
int  pilink_udp_socket_write(struct pilink_udp_socket_s *net, const void *buffer, int size);


#ifdef __cplusplus
}
#endif

#endif
